#ifndef _LCD_COM_H_
#define _LCD_COM_H_

#include "mytype.h"
#include "com_def.h"
#include "mem_buffer.h"

#ifdef __cplusplus
extern "C"
{
#endif

	typedef enum
	{
		LCD_COM_CMD_BEGIN = 0x01,
		LCD_COM_CMD_END,

		LCD_COM_CMD_FONT_SET,
		LCD_COM_CMD_HALF_EN,
		LCD_COM_CMD_HALF_DIS,
		LCD_COM_CMD_ANTI,
		LCD_COM_CMD_NORMAL,
		LCD_COM_CMD_SPACE_SET,

		LCD_COM_CMD_DOT_SET,
		LCD_COM_CMD_DOT_CLR,
		LCD_COM_CMD_RAM_FILL,
		LCD_COM_CMD_SQUARE,
		LCD_COM_CMD_SQUARE_FILL,

		LCD_COM_CMD_CIRCLE,
		LCD_COM_CMD_MOVE_TO,
		LCD_COM_CMD_LINE_TO,

		LCD_COM_CMD_IMAGE,
		LCD_COM_CMD_PUT_NUMS,
		LCD_COM_CMD_ALIGN_EXT_PUTS,
	} lcd_com_cmd_type;

	typedef struct
	{
		const void *font;
		ii16 wide;
		ii16 high;
	} lcd_com_font_type;

	typedef struct
	{
		const void *img;
		ii16 wide;
		ii16 high;
	} lcd_com_img_type;

	typedef struct
	{
		void (*font_set)(uu8 Fontx, uu8 Fonty, const uu8 *Ascii); 
		void (*half_en)(void);									  
		void (*half_dis)(void);									  
		void (*anti)(void);										  
		void (*normal)(void);									  
		void (*space_set)(uu8 Space);							  

		void (*dot_set)(ii16 x, ii16 y);						 
		void (*dot_clr)(ii16 x, ii16 y);						 
		void (*ram_fill)(uu8 Val);								 
		void (*square)(ii16 x0, ii16 y0, ii16 x1, ii16 y1);		 
		void (*square_fill)(ii16 x0, ii16 y0, ii16 x1, ii16 y1); 

		void (*circle)(ii16 x, ii16 y, ii16 r);
		void (*move_to)(ii16 x0, ii16 y0); 
		void (*line_to)(ii16 x1, ii16 y1); 

		void (*imgage)(ii16 x, ii16 y, ii16 wide, ii16 high, unsigned char const *pImg);
		void (*put_nums)(ii16 x, ii16 y, const char *DispStr); 
		void (*alain_ext_puts)(ii16 x, ii16 y, const char *str, uu16 mode);
	} lcd_com_opt_type;

	typedef struct
	{
		com_obj_type *com;

		const lcd_com_img_type *img_list;
		const lcd_com_font_type *font_list;
		const lcd_com_opt_type *opt;
		void (*slv_callback)(uu08* dat);
		mem_fbuf_type slave_buff;
		uu08 message_error;
		uu08 update_req; 
	} lcd_com_obj_type;

	void lcd_com_init(lcd_com_obj_type *obj);

	void lcd_com_mst_begin(void);
	void lcd_com_mst_end(void);
	void lcd_com_mst_font_set(uu08 sel);
	void lcd_com_mst_half_en(void);
	void lcd_com_mst_half_dis(void);
	void lcd_com_mst_anti(void);
	void lcd_com_mst_normal(void);
	void lcd_com_mst_space_set(uu08 space);
	void lcd_com_mst_dot_set(ii16 x, ii16 y);
	void lcd_com_mst_dot_clr(ii16 x, ii16 y);
	void lcd_com_mst_ram_fill(UU08 val);
	void lcd_com_mst_square(ii16 x, ii16 y, ii16 x1, ii16 y1);
	void lcd_com_mst_square_fill(ii16 x, ii16 y, ii16 x1, ii16 y1);
	void lcd_com_mst_cycle(ii16 x, ii16 y, ii16 r);
	void lcd_com_mst_move_to(ii16 x, ii16 y);
	void lcd_com_mst_line_to(ii16 x, ii16 y);
	void lcd_com_mst_image(ii16 x, ii16 y, UU08 sel);
	void lcd_com_mst_put_nums(ii16 x, ii16 y, const char *str);
	void lcd_com_mst_put_text(ii16 x, ii16 y, uu16 mode, const char *str);
	void lcd_com_mst_fmt(ii16 x, ii16 y, uu16 mode, const char* fmt, ...);
	void lcd_com_mst_send(UU08* buf, UU08 len); 

	void lcd_com_slv_poll(void);
	extern const lcd_com_opt_type lcd_com_yl_api;
	extern const lcd_com_opt_type lcd_com_xh_api;
	
#ifdef __cplusplus
}
#endif

#endif 
